module turn_test_fkoa {
	export class 过 extends TriggerEvent{
		constructor(public obj:unknown) {
			super()
		}
		readonly event_name: string = "过"
		readonly autoForward: boolean = true
	}
	function _TRIG_选中单位_FUNC(this: void, 当前触发器: Trigger, e:unknown) {
		if (true) {
		}
	}
	export let 选中单位 = base.trigger_new(_TRIG_选中单位_FUNC, [], false, undefined, true)
	function _TRIG_取消选中单位_FUNC(this: void, 当前触发器: Trigger, e:unknown) {
		if (true) {
		}
	}
	export let 取消选中单位 = base.trigger_new(_TRIG_取消选中单位_FUNC, [], false, undefined, true)
	function _TRIG_trg_进入战斗_FUNC(this: void, 当前触发器: Trigger, e:event_回合制战斗_进入) {
		if (true) {
			turn_test_fkoa.ui_大招面板.show = true;
			turn_test_fkoa.ui_队列面板.show = true;
		}
	}
	export let trg_进入战斗 = base.trigger_new(_TRIG_trg_进入战斗_FUNC, [], false, undefined, true)
	function _TRIG_trg_退出战斗_FUNC(this: void, 当前触发器: Trigger, e:event_回合制战斗_退出) {
		if (true) {
			turn_test_fkoa.ui_大招面板.show = false;
			turn_test_fkoa.ui_队列面板.show = false;
		}
	}
	export let trg_退出战斗 = base.trigger_new(_TRIG_trg_退出战斗_FUNC, [], false, undefined, true)
	export let ui_队列_行动框array: Array<_OBJ__gui_ctrl_gui_ctrl> | undefined = new Array<_OBJ__gui_ctrl_gui_ctrl>();
	export let ui_队列面板: _OBJ__gui_ctrl_panel | undefined = base.gui_get_part_as<any>(base.gui_get_main_page(), "单位列表框");
	function _TRIG_队列更新_FUNC(this: void, 当前触发器: Trigger, e:event_队列更新) {
		let 单个框: _OBJ__gui_ctrl_gui_ctrl | undefined;
		let 单位: Unit | undefined;
		let 单位列表框: _OBJ__gui_ctrl_gui_ctrl = base.gui_get_part_as<_OBJ__gui_ctrl_gui_ctrl>(base.gui_get_main_page(), "单位列表框");
		if (true) {
			if (turn_test_fkoa.ui_队列_行动框array !== undefined) {
				for (let [遍历到的数组索引, 遍历到的数组元素] of base.ArrayIterator(turn_test_fkoa.ui_队列_行动框array as unknown as Array<_OBJ__gui_ctrl_gui_ctrl>)) {
					base.gui_destory(遍历到的数组元素);
				}
			} else {
				log.warn("不能遍历：turn_test_fkoa.ui_队列_行动框array")
			}
			turn_test_fkoa.ui_队列_行动框array = new Array<_OBJ__gui_ctrl_gui_ctrl>();
			if (e.单位队列 !== undefined) {
				for (let [遍历到的数组索引, 遍历到的数组元素] of base.ArrayIterator(e.单位队列 as unknown as Array<number>)) {
					单位 = base.get_unit_from_id(遍历到的数组元素);
					单个框 = base.gui_new_component((("$$gameui.template@gui_ctrl.sci_1_minor_btn") as unknown as IdPreset<"template@gui_ctrl_id">));
					base.gui_set_prop2(单个框, "text", 单位.get_show_name());
					if (((遍历到的数组索引 == 0))) {
						base.gui_set_prop2(单个框, "text_color", "#ff0000");
					} else {
						base.gui_set_prop2(单个框, "text_color", "#ffffff");
					}
					turn_test_fkoa.ui_队列_行动框array.push(单个框);
					base.gui_move_to_new_parent(单个框, 单位列表框);
				}
			} else {
				log.warn("不能遍历：e.单位队列")
			}
		}
	}
	export let 队列更新 = base.trigger_new(_TRIG_队列更新_FUNC, [], true, undefined, true)
	function _TRIG_队列更新_new_FUNC(this: void, 当前触发器: Trigger, e:event_队列更新_new) {
		let 单个框: _OBJ__gui_ctrl_gui_ctrl | undefined;
		let 单位: Unit | undefined;
		let 单位列表框: _OBJ__gui_ctrl_gui_ctrl = base.gui_get_part_as<_OBJ__gui_ctrl_gui_ctrl>(base.gui_get_main_page(), "单位列表框");
		if (true) {
			if (turn_test_fkoa.ui_队列_行动框array !== undefined) {
				for (let [遍历到的数组索引, 遍历到的数组元素] of base.ArrayIterator(turn_test_fkoa.ui_队列_行动框array as unknown as Array<_OBJ__gui_ctrl_gui_ctrl>)) {
					base.gui_destory(遍历到的数组元素);
				}
			} else {
				log.warn("不能遍历：turn_test_fkoa.ui_队列_行动框array")
			}
			turn_test_fkoa.ui_队列_行动框array = new Array<_OBJ__gui_ctrl_gui_ctrl>();
			if (e.单位队列 !== undefined) {
				for (let [遍历到的数组索引, 遍历到的数组元素] of base.ArrayIterator(e.单位队列 as unknown as Array<number>)) {
					let 行动类型: number | undefined = e.行动类型队列[遍历到的数组索引];
					单位 = base.get_unit_from_id(遍历到的数组元素);
					单个框 = base.gui_new_component((("$$gameui.template@gui_ctrl.sci_1_minor_btn") as unknown as IdPreset<"template@gui_ctrl_id">));
					if (((遍历到的数组索引 == 0))) {
						base.gui_set_prop2(单个框, "text_color", "#ffcc00");
					} else {
						base.gui_set_prop2(单个框, "text_color", "#999999");
					}
					if (((行动类型 == 1))) {
						// 普通回合
						单个框.layout.relative[1] = 0;
						base.gui_set_prop2(单个框, "text", 单位.get_show_name());
					} else {
						// 大招回合
						单个框.layout.relative[1] = 50;
						base.gui_set_prop2(单个框, "text", 单位.get_show_name().concat("[大招]"));
					}
					turn_test_fkoa.ui_队列_行动框array.push(单个框);
					base.gui_move_to_new_parent(单个框, 单位列表框);
				}
			} else {
				log.warn("不能遍历：e.单位队列")
			}
		}
	}
	export let 队列更新_new = base.trigger_new(_TRIG_队列更新_new_FUNC, [], false, undefined, true)
	function _TRIG_玩家_切换场景_FUNC(this: void, 当前触发器: Trigger, e:event_切换地图黑屏) {
		if (((e.跳转玩家 == base.player_local()))) {
			log.info("客户端-跳转场景", e.转场时间, e.跳转玩家);
			turn_test_fkoa.黑屏_淡入((e.转场时间 / 2));
			base.timer_wait((e.转场时间 / 2), (计时器:Timer):void => {
				turn_test_fkoa.黑屏_淡出((e.转场时间 / 2));
			});
		}
	}
	export let 玩家_切换场景 = base.trigger_new(_TRIG_玩家_切换场景_FUNC, [], false, undefined, true)
	export let 黑屏_计时器: undefined;
	export let 黑屏_淡入:(时间:number)=>undefined = (时间:number):undefined => {
		let pulse: number = 0.02;
		let count: number = 0;
		let max: number = base.math.ceil((时间 / pulse));
		let 黑屏panel: _OBJ__gui_ctrl_panel = base.gui_get_part_as<any>(base.gui_get_main_page(), "panel_跳转黑屏");
		黑屏panel.opacity = 0;
		黑屏panel.show = true;
		base.timer_timer(pulse, max, (计时器:Timer):void => {
			count = (count + 1);
			黑屏panel.opacity = (count / max);
		});
	}
	export let 黑屏_淡出:(时间:number)=>undefined = (时间:number):undefined => {
		let pulse: number = 0.02;
		let max: number = base.math.ceil((时间 / pulse));
		let count: number = max;
		let 黑屏panel: _OBJ__gui_ctrl_panel = base.gui_get_part_as<any>(base.gui_get_main_page(), "panel_跳转黑屏");
		黑屏panel.opacity = 1;
		黑屏panel.show = true;
		base.timer_timer(pulse, max, (计时器:Timer):void => {
			count = (count - 1);
			黑屏panel.opacity = (count / max);
			if (((count <= 0))) {
				黑屏panel.show = false;
			} else {
			}
		});
	}
	export class event_申请释放大招 extends TriggerEvent{
		constructor(public obj:base.Game, public 单位id:number) {
			super()
		}
		readonly event_name: string = "event_申请释放大招"
		readonly autoForward: boolean = true
	}
	export let 记录_大招单位id: Array<number> | undefined;
	export let 记录_大招技能id: Array<IdPreset<"spell_id">> | undefined;
	export let 记录_大招能量: Array<number> | undefined;
	export let 记录_大招能量上限: Array<number> | undefined;
	export let ui_大招_图标: Array<_OBJ__gui_ctrl_label> = new Array<_OBJ__gui_ctrl_label>(base.gui_get_part_as<any>(base.gui_get_main_page(), "大招icon1"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招icon2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招icon3"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招icon4"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招icon5"));
	export let ui_大招面板: _OBJ__gui_ctrl_panel = base.gui_get_part_as<any>(base.gui_get_main_page(), "大招列表框");
	export let ui_大招_暗: Array<_OBJ__gui_ctrl_label> = new Array<_OBJ__gui_ctrl_label>(base.gui_get_part_as<any>(base.gui_get_main_page(), "大招dark1"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招dark2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招dark3"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招dark4"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招dark5"));
	export let ui_大招_按钮: Array<_OBJ__gui_ctrl_button> = new Array<_OBJ__gui_ctrl_button>(base.gui_get_part_as<any>(base.gui_get_main_page(), "大招bt1"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招bt2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招bt3"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招bt4"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招bt5"));
	export let ui_大招_单位名: Array<_OBJ__gui_ctrl_label> = new Array<_OBJ__gui_ctrl_label>(base.gui_get_part_as<any>(base.gui_get_main_page(), "大招ut1"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招ut2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招ut3"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招ut4"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招ut5"));
	export let ui_大招_技能名: Array<_OBJ__gui_ctrl_label> = new Array<_OBJ__gui_ctrl_label>(base.gui_get_part_as<any>(base.gui_get_main_page(), "大招st1"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招st2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招st2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招st2"), base.gui_get_part_as<any>(base.gui_get_main_page(), "大招st2"));
	export let func_申请释放大招:(按钮ID:number)=>undefined = (按钮ID:number):undefined => {
		base.send_custom_event(new turn_test_fkoa.event_申请释放大招(((base.game) as unknown as base.Game), turn_test_fkoa.记录_大招单位id[(按钮ID - 1)]));
	}
	export let func_大招面板刷新:()=>undefined = ():undefined => {
		// 先判断是否需要显示大招面板
		if ((((turn_test_fkoa.记录_大招单位id == undefined) || (turn_test_fkoa.记录_大招单位id[0] == undefined)))) {
			if (((turn_test_fkoa.记录_大招单位id == undefined))) {
				log.info("return 1", turn_test_fkoa.记录_大招单位id);
			} else {
				log.info("return 2", turn_test_fkoa.记录_大招单位id[0]);
			}
			return undefined;
		} else {
		}
		// 过一遍，把信息显示出来
		if (turn_test_fkoa.ui_大招_按钮 !== undefined) {
			for (let [索引, ui_按钮] of base.ArrayIterator(turn_test_fkoa.ui_大招_按钮 as unknown as Array<_OBJ__gui_ctrl_button>)) {
				let ui_图标: _OBJ__gui_ctrl_label = turn_test_fkoa.ui_大招_图标[索引];
				let ui_技能名: _OBJ__gui_ctrl_label = turn_test_fkoa.ui_大招_技能名[索引];
				let ui_单位名: _OBJ__gui_ctrl_label = turn_test_fkoa.ui_大招_单位名[索引];
				let ui_暗: _OBJ__gui_ctrl_label = turn_test_fkoa.ui_大招_暗[索引];
				let 单位: Unit | undefined;
				let 单位Id: number | undefined = turn_test_fkoa.记录_大招单位id[索引];
				let 技能Id: IdPreset<"spell_id"> | undefined = turn_test_fkoa.记录_大招技能id[索引];
				let 能量: number | undefined = turn_test_fkoa.记录_大招能量[索引];
				let 能量上限: number | undefined = turn_test_fkoa.记录_大招能量上限[索引];
				let 技能数编: _OBJ__spell_Spell | undefined;
				单位 = base.get_unit_from_id(单位Id);
				if (((单位 == undefined))) {
					ui_按钮.show = false;
					// 没有单位，隐藏UI
				} else {
					技能数编 = base.eff.cache_ts<_OBJ__spell_Spell>(技能Id);
					ui_单位名.text = 单位.get_show_name();
					ui_技能名.text = base.i18n.get_text_ex(技能数编.Name, base.i18n.get_lang());
					ui_图标.image = 技能数编.IconName;
					log.info("面板刷新-能量", 能量, 能量上限);
					turn_test_fkoa.func_设置单位大招能量(索引, 能量);
					ui_按钮.show = true;
				}
			}
		} else {
			log.warn("不能遍历：turn_test_fkoa.ui_大招_按钮")
		}
		turn_test_fkoa.ui_大招面板.show = true;
	}
	export let func_设置单位大招能量:(id:number, 能量:number)=>undefined = (id:number, 能量:number):undefined => {
		let 能量上限: number = turn_test_fkoa.记录_大招能量上限[id];
		let ui_暗: _OBJ__gui_ctrl_label = turn_test_fkoa.ui_大招_暗[id];
		let ui_按钮: _OBJ__gui_ctrl_button = turn_test_fkoa.ui_大招_按钮[id];
		turn_test_fkoa.记录_大招能量[id] = 能量;
		ui_暗.layout.height = ((1 - (能量 / 能量上限)) * 64);
		log.info("func_设置单位大招能量", id, ((1 - (能量 / 能量上限)) * 64));
		log.info(" - ", 能量, 能量上限);
		if (((能量 >= 能量上限))) {
			ui_按钮.color = "#664400";
		} else {
			ui_按钮.color = "#222222";
		}
	}
	function _TRIG_大招面板_FUNC(this: void, 当前触发器: Trigger, e:event_大招面板刷新) {
		if (true) {
			turn_test_fkoa.记录_大招单位id = e.单位队列;
			turn_test_fkoa.记录_大招技能id = e.技能link;
			turn_test_fkoa.记录_大招能量 = e.能量;
			turn_test_fkoa.记录_大招能量上限 = e.能量上限;
			log.info("客户端-大招面板刷新", e.单位队列, e.技能link, e.能量, e.能量上限);
			turn_test_fkoa.func_大招面板刷新();
		}
	}
	export let 大招面板 = base.trigger_new(_TRIG_大招面板_FUNC, [], false, undefined, true)
	function _TRIG_大招能量刷新_FUNC(this: void, 当前触发器: Trigger, e:event_大招能量刷新) {
		if (true) {
			log.info("大招能量刷新", e.单位, e.能量);
			if (((turn_test_fkoa.记录_大招单位id == undefined))) {
				log.info("记录=nil return");
				return undefined;
			} else {
			}
			if (turn_test_fkoa.记录_大招单位id !== undefined) {
				for (let [索引, 匹配单位] of base.ArrayIterator(turn_test_fkoa.记录_大招单位id as unknown as Array<number>)) {
					if (((e.单位 == 匹配单位))) {
						log.info("设置", 索引, e.能量);
						turn_test_fkoa.func_设置单位大招能量(索引, e.能量);
						break;
					} else {
					}
				}
			} else {
				log.warn("不能遍历：turn_test_fkoa.记录_大招单位id")
			}
		}
	}
	export let 大招能量刷新 = base.trigger_new(_TRIG_大招能量刷新_FUNC, [], false, undefined, true)
	//以下为转发事件
	export class event_切换地图黑屏 extends TriggerEvent{
		constructor(public obj:unknown, public 转场时间:number, public 跳转玩家:Player) {
			super()
		}
		readonly event_name: string = "event_切换地图黑屏"
		readonly autoForward: boolean = false
	}
	export class event_回合制战斗_进入 extends TriggerEvent{
		constructor(public obj:unknown, public player:Player) {
			super()
		}
		readonly event_name: string = "event_回合制战斗_进入"
		readonly autoForward: boolean = false
	}
	export class event_回合制战斗_退出 extends TriggerEvent{
		constructor(public obj:unknown, public player:Player) {
			super()
		}
		readonly event_name: string = "event_回合制战斗_退出"
		readonly autoForward: boolean = false
	}
	export class event_大招能量刷新 extends TriggerEvent{
		constructor(public obj:unknown, public 单位:number, public 能量:number) {
			super()
		}
		readonly event_name: string = "event_大招能量刷新"
		readonly autoForward: boolean = false
	}
	export class event_大招面板刷新 extends TriggerEvent{
		constructor(public obj:unknown, public 单位队列:Array<number>, public 技能link:Array<IdPreset<"spell_id">>, public 能量:Array<number>, public 能量上限:Array<number>) {
			super()
		}
		readonly event_name: string = "event_大招面板刷新"
		readonly autoForward: boolean = false
	}
	export class event_队列更新 extends TriggerEvent{
		constructor(public obj:unknown, public 单位队列:Array<number>) {
			super()
		}
		readonly event_name: string = "event_队列更新"
		readonly autoForward: boolean = false
	}
	export class event_队列更新_new extends TriggerEvent{
		constructor(public obj:unknown, public 单位队列:Array<number>, public 行动类型队列:Array<number>) {
			super()
		}
		readonly event_name: string = "event_队列更新_new"
		readonly autoForward: boolean = false
	}
	export class event_队列更新_插入大招 extends TriggerEvent{
		constructor(public obj:unknown, public 单位队列:Array<number>) {
			super()
		}
		readonly event_name: string = "event_队列更新_插入大招"
		readonly autoForward: boolean = false
	}
	//为触发器添加事件
	trg_进入战斗.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_回合制战斗_进入" })
	trg_退出战斗.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_回合制战斗_退出" })
	队列更新.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_队列更新" })
	队列更新_new.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_队列更新_new" })
	玩家_切换场景.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_切换地图黑屏" })
	大招面板.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_大招面板刷新" })
	大招能量刷新.add_event_common({ obj: ((base.game) as unknown as base.Game), event_name: "event_大招能量刷新" })
}
